<template>
	<div style="background-color: white;overflow: hidden;">
		<h2 class="title">收题本</h2>
		<div style="height: 100vh;overflow: scroll;overflow-x: hidden;">
			<div class="favorites-card" v-for="(Item,index) in CollectQuestionList" :key="Item.id" @click="$router.push('/record')">
				<div class="favorites-meta">
					<div style="font-size: 0.75rem">
						<span class="pubdate is-success" style="color: #c2c2c2;">2020-12-02 21:11:56</span>
						<span> 在《{{Item.testPaperName}}》中收藏：</span>
					</div>
					<div class="meta-title" style="margin-top: 1.625rem;cursor: pointer;">
						<a class="name ellipsis" style="display: flex;">{{index+1}}:<div v-html="`${md(Item.question.content)}`"></div></a>
					</div>
					<div class="meta-status">
						<div>

							<div style="color: #e5e5e5;"></div>
							<div style="margin-top: 0.55rem;">正确答案：{{Item.question.answer}}</div>
						</div>
						<div class="meta-view">
							<button class="el-button el-button--default" @click="collectQuestion(Item.questionId,Item.testPaperId)">
								<span>取消收藏</span>
							</button>
						</div>

					</div>


				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import marked from "marked";
	import {
		HttpManager
	} from "../../../request/Teacher.js"
	import {
		TestManager
	} from '../../../request/test.js'
	export default {
		data() {
			return {
				CollectQuestionList: []
			}
		},
		methods: {
			//获取收藏列表
			collectQuestionList() {
				var parmas = {
					currentPage: 1,
					pageSize: 100
				}
				HttpManager.collectQuestionList(this.qs.stringify(parmas)).then(e => {
					console.log(e.data.data.dataList);
					this.CollectQuestionList = e.data.data.dataList;
				})
			},
			md(content) {
				return marked(content);
			},
			//收藏题目
			collectQuestion(id, testPaperId) {
				var parmas = {
					questionId: id,
					testPaperId: testPaperId
				}
				TestManager.collectQuestion(this.qs.stringify(parmas)).then(e => {
					this.$message({
						message: '取消收藏成功',
						type: 'success'
					});
					this.collectQuestionList();
				}).catch(e => {
					this.$message({
						message: '取消收藏失败',
						type: 'warning'
					});
				})
			},

		},
		created() {
			this.collectQuestionList();
		}
	}
</script>

<style scoped="scoped">
	.title {
		margin: 20px 20px 10px;
	}

	.tabs {
		width: 100%;
		margin: 0 auto;
		height: 72px;
		position: relative;
		box-sizing: border-box;
		display: flex;
		flex-direction: row;
		padding: 28px 30px;
		background-color: white;
	}

	.item-tab {
		width: 64px;
		height: 16px;
		margin-right: 1.875rem;
		font-size: 14px;
		font-weight: 400;
		color: #666;
		line-height: 16px;
		margin-right: 80 px;
		cursor: pointer;
		position: relative;
	}

	.actline {
		width: 25px;
		height: 2px;
		background: #03d3bd;
		position: absolute;
		left: 1px;
		top: 30px;
	}

	.favorites-card {
		border-bottom: 1px solid rgb(231, 231, 231);
		width: 100%;
		min-height: 96px;
		border-radius: 4px;
		background: rgb(255, 255, 255);
		padding: 24px 20px;
		margin-bottom: 0px;
		box-sizing: inherit;
		display: flex;

	}

	.favorites-cover {
		position: relative;
		float: left;
		border-radius: 4px;
		overflow: hidden;
		width: 154px;
		height: 96px;
		margin-right: 24px;
		box-sizing: inherit;
	}

	.favorites-cover img {
		width: 100%;
		height: 100%;
		border-radius: 4px;
		box-sizing: inherit;
		border-style: none;
	}

	.meta-footer {
		display: flex;
		font-size: 16px;
		box-sizing: inherit;
	}

	.meta-status {
		padding: 16px 0px 20px;
		font-size: 14px;
		color: rgb(80, 80, 80);
		line-height: 16px;
		display: flex;
		justify-content: space-between;

	}

	.favorites-meta {
		width: 95%;
	}

	.meta-view {
		margin-right: 2.25rem;
	}

	.meta-title {
		/* height: 24px; */
		line-height: 24px;
		box-sizing: inherit;
	}

	.meta-footer {
		font-size: 16px;
		box-sizing: inherit;
	}

	.view-stat {
		color: rgb(153, 162, 170);
		display: flex;
		-webkit-box-align: center;
		align-items: center;
		margin-right: 25px;
		box-sizing: inherit;
	}
</style>
